a11y: Move ChildrenChanged emitter to ATSPI utilities
authorEmmanuele Bassi <ebassi@gnome.org>
Wed, 21 Oct 2020 14:16:54 +0000 (15:16 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Wed, 21 Oct 2020 14:18:23 +0000 (15:18 +0100)
We are going to use it from GtkAtSpiRoot, which is not a
GtkAtSpiContext.

gtk/a11y/gtkatspicontext.c
gtk/a11y/gtkatspiutils.c
gtk/a11y/gtkatspiutilsprivate.h

index b5ff4cbbc509e8a21dd37e2d8ce2506b899e821a..a3b5d8bb22a7824997bd4f185ee767e4bc850a89 100644 (file)
@@ -816,33 +816,15 @@ emit_children_changed (GtkAtSpiContext         *self,
                        int                      idx,
                        GtkAccessibleChildState  state)
 {
-  const char *change;
-
-  switch (state)
-    {
-    case GTK_ACCESSIBLE_CHILD_STATE_ADDED:
-      change = "add";
-      break;
-
-    case GTK_ACCESSIBLE_CHILD_STATE_REMOVED:
-      change = "remove";
-      break;
-
-    default:
-      g_assert_not_reached ();
-      return;
-    }
-
-  GVariant *ref = gtk_at_spi_context_to_ref (child_context);
+  GVariant *child_ref = gtk_at_spi_context_to_ref (child_context);
   GVariant *context_ref = gtk_at_spi_context_to_ref (self);
 
-  g_dbus_connection_emit_signal (self->connection,
-                                 NULL,
-                                 self->context_path,
-                                 "org.a11y.atspi.Event.Object",
-                                 "ChildrenChanged",
-                                 g_variant_new ("(siiv@(so))", change, idx, 0, ref, context_ref),
-                                 NULL);
+  gtk_at_spi_emit_children_changed (self->connection,
+                                    self->context_path,
+                                    state,
+                                    idx,
+                                    child_ref,
+                                    context_ref);
 }
 
 static void
index 1fef628144916b477f6c74aef64ec5bfa26c65b5..fad5ee10fd812ddc8f6e598a7329f05354664fc0 100644 (file)
@@ -305,3 +305,37 @@ gtk_at_spi_null_ref (void)
 {
   return g_variant_new ("(so)", "", "/org/a11y/atspi/null");
 }
+
+void
+gtk_at_spi_emit_children_changed (GDBusConnection         *connection,
+                                  const char              *path,
+                                  GtkAccessibleChildState  state,
+                                  int                      idx,
+                                  GVariant                *child_ref,
+                                  GVariant                *sender_ref)
+{
+  const char *change;
+
+  switch (state)
+    {
+    case GTK_ACCESSIBLE_CHILD_STATE_ADDED:
+      change = "add";
+      break;
+
+    case GTK_ACCESSIBLE_CHILD_STATE_REMOVED:
+      change = "remove";
+      break;
+
+    default:
+      g_assert_not_reached ();
+      return;
+    }
+
+  g_dbus_connection_emit_signal (connection,
+                                 NULL,
+                                 path,
+                                 "org.a11y.atspi.Event.Object",
+                                 "ChildrenChanged",
+                                 g_variant_new ("(siiv@(so))", change, idx, 0, child_ref, sender_ref),
+                                 NULL);
+}
index 20b0b093055d2046649b0c042a7133d6b940cab0..d54f5896c7938fbca8b80135a77019a27d4adb25 100644 (file)
@@ -31,4 +31,12 @@ gtk_atspi_role_for_context (GtkATContext *context);
 GVariant *
 gtk_at_spi_null_ref (void);
 
+void
+gtk_at_spi_emit_children_changed (GDBusConnection         *connection,
+                                  const char              *path,
+                                  GtkAccessibleChildState  state,
+                                  int                      idx,
+                                  GVariant                *child_ref,
+                                  GVariant                *sender_ref);
+
 G_END_DECLS